package com.zzyl.config;

import com.aliyun.iot20180120.Client;
import com.aliyun.teaopenapi.models.Config;
import com.zzyl.properties.AliIoTConfigProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@Slf4j
public class IotClientConfig {

    @Autowired
    private AliIoTConfigProperties aliIoTConfigProperties;

    @Bean
    public Client instance() throws Exception {
        Config config = new Config();
        // 您的AccessKey ID
        config.setAccessKeyId(aliIoTConfigProperties.getAccessKeyId());
        // 您的AccessKey Secret
        config.setAccessKeySecret(aliIoTConfigProperties.getAccessKeySecret());
// 访问的域名
        config.setRegionId(aliIoTConfigProperties.getRegionId());

        return new Client(config);
    }
}
